<div id="panelExt" style="background-color: AppWorkspace;">
    <input type="text" jqxb-datasource="custCompactDetailExt" jqxb-datamember="Name" />
    <input type="text" jqxb-datasource="custCompactDetailExt" jqxb-datamember="Surname" />
    <table>
        <thead>
            <tr>
                <td>Order Number</td>
                <td>Order Date</td>
                <td colspan="2">Action</td>
            </tr>        
        </thead>
        <tbody jqxb-templatecontainer="custOrdersTpl" jqxb-datasource="custOrders">
            <tr jqxb-template="custOrdersTpl" jqxb-itemdatasourceidx="rowOrder" style="display: none;">
                <td><input type="text" jqxb-itemdatamember="number" /></td>
                <td><input type="text" jqxb-itemdatamember="date" /></td>
                <td></td>
                <td></td>
            </tr>
        </tbody>
    </table>

</div>
<script type="text/javascript">
  /*
    *   jQXB - Dynamic-Widget logic
    *
    */
    var CustomerDetailExt = {}
    CustomerDetailExt.loadCustomer = function (id) {
        jQXB.getJSON('getCustomer.php', { id: id },
                function (data) {
                    jQXB.setDataSource('custCompactDetailExt', data).
                         setDataSource('custOrders', data.ordersList).
                         doBind('custCompactDetailExt').
                         doBind('custOrders');
                });
    }
	
	CustomerDetailExt.clearSubscription = function(){
		jQXBM.unsubscribeMessage(jQXBtopics.MSG_CUSTOMER_SELECTED, CustomerDetailExt.loadCustomer);
		jQXBM.unsubscribeMessage(jQXBtopics.MSG_PREPARELOADING,CustomerDetailExt.clearSubscription);
	}

    jQuery(document).ready(function () {
		//alert('LoadingExt');
		jQXBM.subscribeMessage(jQXBtopics.MSG_PREPARELOADING,CustomerDetailExt.clearSubscription);
        jQXBM.subscribeMessage(jQXBtopics.MSG_CUSTOMER_SELECTED,CustomerDetailExt.loadCustomer);
		//alert(jQXB.diags.dumpobj(jQXBM.messageSubscribers,"MessageSubscriber","->"));
		//alert('End LoadingExt');
    });
</script>